﻿#region Using directives

using System;
using System.Collections.Generic;
using System.Text;

using Weazel.NativeMath;

using Microsoft.VisualStudio.TestTools.UnitTesting;

#endregion

namespace Weazel.NativeMath.Test
{
	[TestClass]
	public class TestUnsignedSubtraction
	{
		[TestMethod]
		public void TestSubtraction_1()
		{
			Integer a = new Integer(8, 0, false);
			Integer b = new Integer(8, 0, false);
			Assert.AreEqual("0", (a - b).ToDecimalString());
		}

		[TestMethod]
		public void TestSubtraction_2()
		{
			Integer a = new Integer(8, 1, false);
			Integer b = new Integer(8, 0, false);
			Assert.AreEqual("1", (a - b).ToDecimalString());
		}

		[TestMethod]
		public void TestSubtraction_3()
		{
			Integer a = new Integer(8, 10, false);
			Integer b = new Integer(8, 100, false);
			Assert.AreEqual("166", (a - b).ToDecimalString());
		}

		[TestMethod]
		public void TestSubtraction_4()
		{
			Integer a = new Integer(32, "0xFFFFFFFF", false);
			Integer b = new Integer(2, 1, false);
			Assert.AreEqual("fffffffe", (a - b).ToHexadecimalString());
		}

		[TestMethod]
		public void TestSubtraction_5()
		{
			Integer a = new Integer(32, "0xFFFFFFFF", false);
			Integer b = new Integer(64, "0x1FFFFFFFF", false);
			Integer r = new Integer(96, false);

			Integer.Subtract(r, a, b);

			Assert.AreEqual("ffffffffffffffff00000000", r.ToHexadecimalString());
			Assert.AreEqual("ffffffff00000000", (a - b).ToHexadecimalString());
		}

		[TestMethod]
		public void TestSubtraction_7()
		{
			Integer a = new Integer(32, "0xFFFFFFFF", false);
			Integer b = new Integer(96, "0x1FFFFFFFF", false);
			Integer r = new Integer(64, false);

			Integer.Subtract(r, a, b);

			Assert.AreEqual("ffffffff00000000", r.ToHexadecimalString());
			Assert.AreEqual("ffffffffffffffff00000000", (a - b).ToHexadecimalString());
		}

		[TestMethod]
		public void TestSubtraction_8()
		{
			Integer a = new Integer(64, "0xFFFFFFFFF", false);
			Integer b = new Integer(96, "0x1FFFFFFFFE", false);
			Integer r = new Integer(32, false);

			Integer.Subtract(r, a, b);

			Assert.AreEqual("1", r.ToHexadecimalString());
			Assert.AreEqual("fffffffffffffff000000001", (a - b).ToHexadecimalString());
		}

		[TestMethod]
		public void TestSubtraction_9()
		{
			Integer a = new Integer(64, "0x1FFFFFFFF", false);
			Integer b = new Integer(32, "0xFFFFFFFE", false);

			Integer r = new Integer(96, false);
			Integer.Subtract(r, a, b);

			Assert.AreEqual("100000001", r.ToHexadecimalString());
			Assert.AreEqual("100000001", (a - b).ToHexadecimalString());
		}

		[TestMethod]
		public void TestSubtraction_10()
		{
			Integer a = new Integer(96, "0x1FFFFFFFF", false);
			Integer b = new Integer(64, "0xFFFFFFFE", false);

			Integer r = new Integer(32, false);
			Integer.Subtract(r, a, b);

			Assert.AreEqual("1", r.ToHexadecimalString());
			Assert.AreEqual("100000001", (a - b).ToHexadecimalString());
		}

		[TestMethod]
		public void TestSubtraction_11()
		{
			Integer a = new Integer(96, "0x1FFFFFFFF", false);
			Integer b = new Integer(32, "0xFFFFFFFE", false);

			Integer r = new Integer(64, false);
			Integer.Subtract(r, a, b);

			Assert.AreEqual("100000001", r.ToHexadecimalString());
			Assert.AreEqual("100000001", (a - b).ToHexadecimalString());
		}
	}
}
